<!DOCTYPE html>
<html>
  <head>
    <title>MyHtml.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript" src="http://imgcdn.cnbkw.com/mainmaster/pagescript/jquery-1.7.2.min.d24658d0.js"></script>
 
  </head>
  
  <body>
<h1>模拟POST/GET数据</h1><hr>
     <select id="method">
      <option value="POST">POST</option>
      <option value="GET">GET</option>
      <option value="JSON">JSON</option>
     </select>
     <input type="text" id="url" size="60"><br>
     <textarea id="parameter" cols="60" rows="6"></textarea><br>
     <input type="button" value="发 送" onclick="send()">
     <div id="receiver" style="margin-top:10px;border:1px #efefef solid;padding:10px;"></div>
  <script>
  function  send(){
  	var method = $("#method").val();  
  	if($("#url").val()==""){
  		alert("请输入URL");
  	}else{
  	
  		if(method == "JSON"){
  		var myJSONString = JSON.stringify($("#parameter").val())
  		
  			$.ajax({
		         type: "POST",
		         contentType: "application/json; charset=utf-8",
		         url: $("#url").val(),
		         dataType: "html",
		         async: true,
		         cache:false,
		         data: $("#parameter").val()
		         ,
		         success: function (data) {             
		 			$("#receiver").html(data);
		         }, error: function (jqXHR, textStatus, errorThrown) {
		             $("#receiver").html("请求出错！！！！");
		         }
		     });
  		}else{
  			$.ajax({
	         type: method,
	         url: $("#url").val(),
	         dataType: "html",
	         async: true,
	         timeout:25000,
	         cache:false,
	         data: $("#parameter").val()
	         ,
	         success: function (data) {             
	 			$("#receiver").html(data);
	         }, error: function (jqXHR, textStatus, errorThrown) {
	             $("#receiver").html("请求出错！！！！");
	         }
	     });
	    }
  	}
  }
  </script>
  </body>
</html>
